package com.ukao.steward.util;

import android.content.Context;
import android.os.SystemProperties;
import android.provider.Settings;

import java.util.Collection;
import java.util.Map;

/**
 * Created by Administrator on 2016/5/10.
 */
public class CheckUtils {





    /**
     * 字符串
     * @return
     */
    public static boolean isEmpty(CharSequence str) {
        return isNull(str) || str.length() == 0;
    }
    /**
     * 数组
     * @return
     */
    public static boolean isEmpty(Object[] os) {
        return isNull(os) || os.length == 0;
    }

    /**
     * 集合检测
     * @return
     */
    public static boolean isEmpty(Collection<?> l) {
        return isNull(l) || l.isEmpty();
    }
    /**
     * map检测
     * @return
     */
    public static boolean isEmpty(Map<?, ?> m) {
        return isNull(m) || m.isEmpty();
    }

    public static boolean isNull(Object o) {
        return o == null;
    }



    /**
     * 字符串
     * @return
     */
    public static boolean isHttp(String str) {
        return !CheckUtils.isEmpty(str)&&str.length()>4 && !str.substring(0, 4).equals("http");
    }




    public static String  isEmptyString(String str) {
        if ( isNull(str) || str.length() == 0){
            return "";
        }
        return str;
    }


    public static String  isEmptyNumber(Integer str) {

        if ( isNull(str) ){
            return "0.00";
        }else{

            return DecimalUtil.divide(String.valueOf(str),"100");

        }
    }

    /**
     * 判断是否有折扣
     * @param str
     * @return
     */
    public static String  isDiscount(Integer str) {


        if ( isNull(str)||str==100||str==0 ){
            return "";
        }else {

            return String.valueOf((double)str/10);

        }
    }

    public static String  isDiscount(Integer str,int  discountType) {
        if (discountType==2){

            return "多折扣";
        }else {
            if ( isNull(str)||str==100||str==0 ){
                return "无折扣";
            }else {

                return String.valueOf((double)str/10)+"折";

            }

        }


    }

    public static boolean  isEmptyInterExist(Integer str) {

        if ( isNull(str)||str==0){
            return false;
        }else{

            return true;

        }
    }
    /**
     * 是否是小米设备
     * @return
     */
    public  static   boolean  isMIUIDevices(){
        String model=SystemProperties.get("ro.product.model");
        String brand = SystemProperties.get("ro.product.brand");
        if ("SUNMI".equals(brand)&&model.contains("P1")){
            return true;
        }
        return  false;
    }



}
